Quản lý nhân sự công ty bằng c# _ full source code
60.382 lượt xem;
- frmDoiMatKhau.cs
- QuanLyNhanSu /
- project /
1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Data;
5 using System.Drawing;
6 using System.Linq;
7 using System.Text;
8 using System.Windows.Forms;
9 using System.Data.SqlClient;
10 using Telerik.WinControls;
11 using QuanLyNhanSu.Class;
12 namespace QuanLyNhanSu
13 {
14 public partial class frmDoiMatKhau : RadForm
15 {
16 clsUser cUser = new clsUser();
17 public frmDoiMatKhau()
18 {
19 InitializeComponent();
20 }
21
22 private void txtmkcu_Validated(object sender, EventArgs e)
23 {
24 if (cUser.KiemTraHopLe(frmMain.me.sql.GetUser(), txtmkcu.Text.Trim()) == false)
25 {
26 RadMessageBox.Show("\nMật khẩu không hợp lệ !\n", "Thông báo",MessageBoxButtons.OK,RadMessageIcon.Error);
27 txtmkcu.Text = "";
28 this.picNotValidMK.Visible=true;
29 this.picValidMK.Visible=false;
30 }
31 else
32 {
33 this.picNotValidMK.Visible=false;
34 this.picValidMK.Visible=true;
35 }
36 }
37
38 private void txtmkmoi2_Validated(object sender, EventArgs e)
39 {
40 if (txtmkmoi.Text.Trim() != txtmkmoi2.Text.Trim())
41 {
42 RadMessageBox.Show("\nMật khẩu mới không trùng khớp !\n", "Thông báo", MessageBoxButtons.OK, RadMessageIcon.Error);
43 txtmkmoi2.Text = "";
44 txtmkmoi2.Focus();
45 this.picNotValidMKMoi2.Visible = true;
46 this.picNotValidMKMoi.Visible = true;
47
48
49 this.picValidMKMoi2.Visible = false;
50 this.picValidMKMoi.Visible = false;
51 }
52 else
53 {
54 this.picValidMKMoi2.Visible = true;
55 this.picValidMKMoi.Visible = true;
56
57 this.picNotValidMKMoi2.Visible = false;
58 this.picNotValidMKMoi.Visible = false;
59 }
60 }
61
62 private void btnOK_Click(object sender, EventArgs e)
63 {
64 DialogResult rs = RadMessageBox.Show("\nBạn muốn lưu mật khẩu mới ?\n", "Thông báo", MessageBoxButtons.YesNo,RadMessageIcon.Question);
65 if (rs == DialogResult.Yes)
66 {
67 if (txtmkmoi.Text.Trim() != txtmkmoi2.Text.Trim())
68 {
69 RadMessageBox.Show("\nMật khẩu mới không trùng khớp !\n", "Thông báo", MessageBoxButtons.OK, RadMessageIcon.Error);
70 txtmkmoi2.Text = "";
71 txtmkmoi2.Focus();
72 this.picNotValidMKMoi2.Visible = true;
73 this.picNotValidMKMoi.Visible = true;
74
75
76 this.picValidMKMoi2.Visible = false;
77 this.picValidMKMoi.Visible = false;
78
79 }
80 else
81 {
82 this.picValidMKMoi2.Visible = true;
83 this.picValidMKMoi.Visible = true;
84
85 this.picNotValidMKMoi2.Visible = false;
86 this.picNotValidMKMoi.Visible = false;
87 string sqlupd = "Update tbl_User set pass='" + txtmkmoi2.Text.Trim() + "' where id='" + frmMain.me.sql.GetUser() + "'";
88 cUser.sc.Open();
89 SqlCommand cmdupd = new SqlCommand(sqlupd, cUser.sc);
90 try
91 {
92 cmdupd.ExecuteNonQuery();
93 RadMessageBox.Show("\nCập nhật thành công !\n", "Thông báo",MessageBoxButtons.OK,RadMessageIcon.Exclamation);
94 }
95 catch (SqlException ex)
96 {
97 RadMessageBox.Show("" + ex.Errors + " " + ex.Number);
98 }
99 cUser.sc.Close();
100 }
101 }
102 }
103
104 private void txtmkmoi_TextChanged(object sender, EventArgs e)
105 {
106 txtmkmoi2.Text = "";
107 }
108
109 private void txtmkmoi2_TextChanged(object sender, EventArgs e)
110 {
111
112 }
113
114 private void btnCancel_Click(object sender, EventArgs e)
115 {
116 this.Close();
117 }
118 }
119 }
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Data;
5 using System.Drawing;
6 using System.Linq;
7 using System.Text;
8 using System.Windows.Forms;
9 using System.Data.SqlClient;
10 using Telerik.WinControls;
11 using QuanLyNhanSu.Class;
12 namespace QuanLyNhanSu
13 {
14 public partial class frmDoiMatKhau : RadForm
15 {
16 clsUser cUser = new clsUser();
17 public frmDoiMatKhau()
18 {
19 InitializeComponent();
20 }
21
22 private void txtmkcu_Validated(object sender, EventArgs e)
23 {
24 if (cUser.KiemTraHopLe(frmMain.me.sql.GetUser(), txtmkcu.Text.Trim()) == false)
25 {
26 RadMessageBox.Show("\nMật khẩu không hợp lệ !\n", "Thông báo",MessageBoxButtons.OK,RadMessageIcon.Error);
27 txtmkcu.Text = "";
28 this.picNotValidMK.Visible=true;
29 this.picValidMK.Visible=false;
30 }
31 else
32 {
33 this.picNotValidMK.Visible=false;
34 this.picValidMK.Visible=true;
35 }
36 }
37
38 private void txtmkmoi2_Validated(object sender, EventArgs e)
39 {
40 if (txtmkmoi.Text.Trim() != txtmkmoi2.Text.Trim())
41 {
42 RadMessageBox.Show("\nMật khẩu mới không trùng khớp !\n", "Thông báo", MessageBoxButtons.OK, RadMessageIcon.Error);
43 txtmkmoi2.Text = "";
44 txtmkmoi2.Focus();
45 this.picNotValidMKMoi2.Visible = true;
46 this.picNotValidMKMoi.Visible = true;
47
48
49 this.picValidMKMoi2.Visible = false;
50 this.picValidMKMoi.Visible = false;
51 }
52 else
53 {
54 this.picValidMKMoi2.Visible = true;
55 this.picValidMKMoi.Visible = true;
56
57 this.picNotValidMKMoi2.Visible = false;
58 this.picNotValidMKMoi.Visible = false;
59 }
60 }
61
62 private void btnOK_Click(object sender, EventArgs e)
63 {
64 DialogResult rs = RadMessageBox.Show("\nBạn muốn lưu mật khẩu mới ?\n", "Thông báo", MessageBoxButtons.YesNo,RadMessageIcon.Question);
65 if (rs == DialogResult.Yes)
66 {
67 if (txtmkmoi.Text.Trim() != txtmkmoi2.Text.Trim())
68 {
69 RadMessageBox.Show("\nMật khẩu mới không trùng khớp !\n", "Thông báo", MessageBoxButtons.OK, RadMessageIcon.Error);
70 txtmkmoi2.Text = "";
71 txtmkmoi2.Focus();
72 this.picNotValidMKMoi2.Visible = true;
73 this.picNotValidMKMoi.Visible = true;
74
75
76 this.picValidMKMoi2.Visible = false;
77 this.picValidMKMoi.Visible = false;
78
79 }
80 else
81 {
82 this.picValidMKMoi2.Visible = true;
83 this.picValidMKMoi.Visible = true;
84
85 this.picNotValidMKMoi2.Visible = false;
86 this.picNotValidMKMoi.Visible = false;
87 string sqlupd = "Update tbl_User set pass='" + txtmkmoi2.Text.Trim() + "' where id='" + frmMain.me.sql.GetUser() + "'";
88 cUser.sc.Open();
89 SqlCommand cmdupd = new SqlCommand(sqlupd, cUser.sc);
90 try
91 {
92 cmdupd.ExecuteNonQuery();
93 RadMessageBox.Show("\nCập nhật thành công !\n", "Thông báo",MessageBoxButtons.OK,RadMessageIcon.Exclamation);
94 }
95 catch (SqlException ex)
96 {
97 RadMessageBox.Show("" + ex.Errors + " " + ex.Number);
98 }
99 cUser.sc.Close();
100 }
101 }
102 }
103
104 private void txtmkmoi_TextChanged(object sender, EventArgs e)
105 {
106 txtmkmoi2.Text = "";
107 }
108
109 private void txtmkmoi2_TextChanged(object sender, EventArgs e)
110 {
111
112 }
113
114 private void btnCancel_Click(object sender, EventArgs e)
115 {
116 this.Close();
117 }
118 }
119 }